#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <time.h>

using namespace std;

vector<int> bubble_sort(vector<int> arr)
{
    int n = arr.size() - 1;

    for (int i = 0; i < n; i++) 
    {
        for (int j = 0; j < n - i; j++) 
        {
            if (arr[j] > arr[j + 1]) {
                int a = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = a;
            }
        }
    }

    return arr;
}

void measure_sort(string fname, int nums)
{
    ifstream input(fname);

    vector<int> arr(nums, nums);

    for (int i = 0; i < nums; i++) {
        input >> arr[i];
    }

    input.close();

    clock_t start = clock();

    arr = bubble_sort(arr);

    clock_t end = clock();

    double res = ((double) (end - start)) / CLOCKS_PER_SEC * 1000;
    cout << fname << " " << (int)res << endl;
}

int main()
{
    measure_sort("m1_sorted.txt", 5000);
    measure_sort("m2_reverse.txt", 5000);
    measure_sort("m3_shuffle.txt", 5000);

    return 0;
}
